<?php
$active=array('active','','','','','','');
include 'header.php';
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}

if (isset($_GET['p'])) {
	$page=$_GET['p'];
}else{
	$page=1;
}
$pageSize=15;
$query_count = $mysqli->query("select count(id) as count from play ");
$row=$query_count->fetch_array();
$total=$row['count'];
$total_page=1;
if ($total) {
	if($total % $pageSize){
		$total_page=(int)($total/$pageSize)+1;
	}else{
		$total_page=($total/$pageSize);
	}
}
$pageUrl='?&c=hx&p=';
$query=$mysqli->query("SELECT * FROM play  order by id desc limit ".($page-1)*$pageSize.", $pageSize ");

$jName=array(
		1=>'一等奖',
		2=>'吃货奖',
		3=>'免单奖',
		4=>'立减2元' 
);
?>
	<div class="wrap js-check-wrap">
	    <div style="width:100%;height:40px;">
	    总用户数(UV)：<?php 
	    $quserC = $mysqli->query("select count(id) as count from users ");
	    $rowUser=$quserC->fetch_array();
	    $userNum=$rowUser['count'];
	    echo $userNum;
	    
	    ?>, 玩游戏次数：<?php echo $total;  ?>
	    </div>
        <div style="width:100%;height:40px;">
			<a href="?c=home-down" class="btn btn-primary">导出数据</a>
		</div>
		<form class="js-ajax-form" action="" method="post">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">Openid</th>
						<th width="50">微信昵称</th>
						<th width="50">微信头像</th>
						<th width="50">奖品类型</th>
						<th width="50">多少条鱼</th>
						<th width="50">券码</th>
						<th width="50">领取情况</th>
						<th width="50">参与时间</th>
					</tr>
				</thead>
				<?php  
				while ($list=$query->fetch_assoc()){
		
					
					$name=$avatar='';
					
					$queryU=$mysqli->query("SELECT * FROM users where openid='".$list['openid']."' limit 0,1");
						
					if($queryU->num_rows>0){
						 $getU=$queryU->fetch_array();
						 $name=$getU['nickname'];
						 $avatar=$getU['avatar'];
						 
					}
				 
					
 
				         ?>
				<tr>
				        <td><b><?php echo $list['openid']  ?></b></td>
						<td><b><?php echo base64_decode($name); ?></b></td>
						<td><b><img width="60" src="<?php echo $avatar; ?>"></b></td>
						<td><b><?php echo $jName[$list['jid']]; ?></b></td>
						<td><b><?php echo $list['tiao']; ?></b></td>
						<td><b><?php echo $list['thecode']; ?></b></td>
						
						<td><b>
						
						<?php 
						if('yes' == $list['ling1']){
						    echo '已领取'; 
						}else{
						    echo '未领取'; 
						}
						?>
						
						
						</b></td>
				 
						<td><b><?php echo $list['createtime'] ?></b></td>
					</tr>
			    <?php } 
			    
			    
			    $mysqli->close();
			    ?>		
					 
			</table>
			 
		</form>
		<?php  include('_page.php'); ?>
	</div>



<?php
include 'foot.php';
?>